package _spring_test._tests._Converter;

import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author: huangya
 * @Date: 2019/12/16
 * @Description:
 */
public class MyConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return format.parse((String) source);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

}
